package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAfterLogisticsCompany;
import com.ruoyi.zsyh.service.IZsyhAfterLogisticsCompanyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物流公司Controller
 * 
 * @author yuexl
 * @date 2022-09-13
 */
@Controller
@RequestMapping("/zsyh/afterLogisticsCompany")
public class ZsyhAfterLogisticsCompanyController extends BaseController
{
    private String prefix = "zsyh/afterLogisticsCompany";

    @Autowired
    private IZsyhAfterLogisticsCompanyService zsyhAfterLogisticsCompanyService;

    @RequiresPermissions("zsyh:afterLogisticsCompany:view")
    @GetMapping()
    public String afterLogisticsCompany()
    {
        return prefix + "/afterLogisticsCompany";
    }

    /**
     * 查询物流公司列表
     */
    @RequiresPermissions("zsyh:afterLogisticsCompany:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAfterLogisticsCompany zsyhAfterLogisticsCompany)
    {
        startPage();
        List<ZsyhAfterLogisticsCompany> list = zsyhAfterLogisticsCompanyService.selectZsyhAfterLogisticsCompanyList(zsyhAfterLogisticsCompany);
        return getDataTable(list);
    }

    /**
     * 导出物流公司列表
     */
    @RequiresPermissions("zsyh:afterLogisticsCompany:export")
    @Log(title = "物流公司", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAfterLogisticsCompany zsyhAfterLogisticsCompany)
    {
        List<ZsyhAfterLogisticsCompany> list = zsyhAfterLogisticsCompanyService.selectZsyhAfterLogisticsCompanyList(zsyhAfterLogisticsCompany);
        ExcelUtil<ZsyhAfterLogisticsCompany> util = new ExcelUtil<ZsyhAfterLogisticsCompany>(ZsyhAfterLogisticsCompany.class);
        return util.exportExcel(list, "物流公司数据");
    }

    /**
     * 新增物流公司
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存物流公司
     */
    @RequiresPermissions("zsyh:afterLogisticsCompany:add")
    @Log(title = "物流公司", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAfterLogisticsCompany zsyhAfterLogisticsCompany)
    {
        return toAjax(zsyhAfterLogisticsCompanyService.insertZsyhAfterLogisticsCompany(zsyhAfterLogisticsCompany));
    }

    /**
     * 修改物流公司
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhAfterLogisticsCompany zsyhAfterLogisticsCompany = zsyhAfterLogisticsCompanyService.selectZsyhAfterLogisticsCompanyById(id);
        mmap.put("zsyhAfterLogisticsCompany", zsyhAfterLogisticsCompany);
        return prefix + "/edit";
    }

    /**
     * 修改保存物流公司
     */
    @RequiresPermissions("zsyh:afterLogisticsCompany:edit")
    @Log(title = "物流公司", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAfterLogisticsCompany zsyhAfterLogisticsCompany)
    {
        return toAjax(zsyhAfterLogisticsCompanyService.updateZsyhAfterLogisticsCompany(zsyhAfterLogisticsCompany));
    }

    /**
     * 删除物流公司
     */
    @RequiresPermissions("zsyh:afterLogisticsCompany:remove")
    @Log(title = "物流公司", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAfterLogisticsCompanyService.deleteZsyhAfterLogisticsCompanyByIds(ids));
    }
}
